package com.ruoyi.lab.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.lab.domain.LabSeatOperate;
import com.ruoyi.lab.service.ILabSeatOperateService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 座位操作日志Controller
 * 
 * @author dn
 * @date 2024-01-01
 */
@RestController
@RequestMapping("/lab/seatOperate")
public class LabSeatOperateController extends BaseController
{
    @Autowired
    private ILabSeatOperateService labSeatOperateService;

    /**
     * 查询座位操作日志列表
     */
    @PreAuthorize("@ss.hasPermi('lab:seatOperate:list')")
    @GetMapping("/list")
    public TableDataInfo list(LabSeatOperate labSeatOperate)
    {
        startPage();
        List<LabSeatOperate> list = labSeatOperateService.selectLabSeatOperateList(labSeatOperate);
        return getDataTable(list);
    }

    /**
     * 导出座位操作日志列表
     */
    @PreAuthorize("@ss.hasPermi('lab:seatOperate:export')")
    @Log(title = "座位操作日志", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LabSeatOperate labSeatOperate)
    {
        List<LabSeatOperate> list = labSeatOperateService.selectLabSeatOperateList(labSeatOperate);
        ExcelUtil<LabSeatOperate> util = new ExcelUtil<LabSeatOperate>(LabSeatOperate.class);
        util.exportExcel(response, list, "座位操作日志数据");
    }

    /**
     * 获取座位操作日志详细信息
     */
    @PreAuthorize("@ss.hasPermi('lab:seatOperate:query')")
    @GetMapping(value = "/{operateId}")
    public AjaxResult getInfo(@PathVariable("operateId") Long operateId)
    {
        return success(labSeatOperateService.selectLabSeatOperateByOperateId(operateId));
    }

    /**
     * 新增座位操作日志
     */
    @PreAuthorize("@ss.hasPermi('lab:seatOperate:add')")
    @Log(title = "座位操作日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LabSeatOperate labSeatOperate)
    {
        return toAjax(labSeatOperateService.insertLabSeatOperate(labSeatOperate));
    }

    /**
     * 修改座位操作日志
     */
    @PreAuthorize("@ss.hasPermi('lab:seatOperate:edit')")
    @Log(title = "座位操作日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LabSeatOperate labSeatOperate)
    {
        return toAjax(labSeatOperateService.updateLabSeatOperate(labSeatOperate));
    }

    /**
     * 删除座位操作日志
     */
    @PreAuthorize("@ss.hasPermi('lab:seatOperate:remove')")
    @Log(title = "座位操作日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{operateIds}")
    public AjaxResult remove(@PathVariable Long[] operateIds)
    {
        return toAjax(labSeatOperateService.deleteLabSeatOperateByOperateIds(operateIds));
    }
}
